package xx;

import java.util.Iterator;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class manage {

    public static void main(String[] args) {

        int a[] = new int[100];

        Scanner sc = new Scanner(System.in);
        int x, b = 0, f;

        for (;;) {
            System.out.println("输入1 2 3 4选择");
            System.out.println("1.添加元素");
            System.out.println("2.修改元素");
            System.out.println("3.查找元素");
            System.out.println("4.删除元素");
            System.out.println("输入#结束程序");
            LinkedList<Integer>list=new LinkedList<Integer>();
            List<Integer> list1 = new ArrayList<Integer>();
            if (sc.hasNext("#")) {
                break;
            }
            int o = sc.nextInt();
            if (o == 1) {

                System.out.println("输入添加的元素");

                x = sc.nextInt();
                a[b] = x;
                b++;

                for (int i = 0; i < b; i++) {
                    f = a[i];
                    list1.add(f);
                }
                //System.out.println(list1);
            }
            if (o == 2) {
                System.out.println("输入修改元素的位置");
                Integer c = sc.nextInt();
                System.out.println("输入修改元素的值");
                Integer h = sc.nextInt();
                list1.set(c - 1, h);
                //System.out.println(list1);
            }
            if (o == 3) {
                System.out.println("输入查找的元素");
                Integer y = sc.nextInt();
                if (list1.contains(y)) {
                    System.out.println("存在");
                } else {
                    System.out.println("不存在");
                }
            }
            if (o == 4) {
                System.out.println("输入删除的元素");
                Integer l = sc.nextInt();
                Iterator<Integer> it = list1.iterator();
                Integer p;
                while (it.hasNext()) {
                    p = it.next();

                    if (p.equals(l)) {
                        it.remove();

                    }

                }

            }
            System.out.println(list1);
        }
    }
}